<template>
	<view class="container bg">
		<view v-if="list.length===0">
			<luanqing-empty :show="true" text="没有更多数据啦" textColor="#000"></luanqing-empty>
		</view>
		<view class="main">
			<view class="cardContainer" v-for="(item,index) in list" :key='index'>
				<view class="cardHead xy_center_between">
					<view class="cardHeadLeft xy_center">
						<image :src="item.shop.logo" mode="" class="avatar"></image>
						<text>{{item.shop.shop_name}}</text>
					</view>
					<view class="time">
						{{item.createtime | fomatTime}}
					</view>
				</view>
				<view class="cardContent">
					<view class="cover">
						<image :src="item.image" mode=""></image>
					</view>
					<view class="intro">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<view class="tip">
			没有更多数据喽～
		</view>
	</view>
</template>

<script>
	import fomatTime from '../../common/js/timeTool.js'
	export default{
		data(){
			return{
				token:'',
				shop_id:'',//机构id
				list:[],
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			console.log(option.id); //打印出上个页面传递的参数。
			this.shop_id = option.id;
			uni.showLoading({
				title: "加载中...",
				mask: true
			})
			uni.getStorage({
				key: 'user_info',
				success: (res) => {
					this.token = res.data.token;
					this.getlist();
				},
				fail() {
					uni.redirectTo({
						url: '../login/auth'
					});
				}
			});
		},
		methods:{
			getlist(){
				this.$request('/api/wxapp/v2/goods/index/activitiesList',{
					'token':this.token,
					'shop_id':this.shop_id
				}).then(res=>{
					if(res.code===1){
						uni.hideLoading();
						this.list = res.data;
					}
				})
			}
		},
		filters: {
			fomatTime
		}
	}
</script>

<style scoped lang="scss">
	.bg{
		background: #F6F6F6;
		overflow: auto;
	}
	.tip{
		font-size: 13px;
		color: #999999;
		margin-top: 20px;
		text-align: center;
	}
	.cardContainer {
		width: 710rpx;
		background: #FFFFFF;
		box-shadow: 0px 2px 10px 0px #E9EBF6;
		border-radius: 8rpx;
		margin: 20px auto 0px auto;
	
		.avatar {
			width: 60rpx;
			height: 60rpx;
			border-radius: 50%;
			margin-right: 10px;
		}
	
		.cardHead {
			padding: 10px;
			box-sizing: border-box;
	
			.name {
				font-size: 15px;
				color: #333333;
			}
			.time{
				font-size: 15px;
				color: #8B8B8B;
			}
		}
	
		.cover image {
			display: block;
			width: 100%;
			height: 320rpx;
		}
		.intro {
			width: 630rpx;
			margin: 0 auto;
			font-size: 15px;
			color: #8B8B8B;
			line-height: 48rpx;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
			padding-bottom: 20rpx;
			padding-top: 18rpx;
		}
	}
</style>
